<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
	<form class="form-horizontal buyinfor-form" id="commentForma">
		<div class="current-state-bno">
			<div class="submit-buttonleft">
				<button id="pksave" class="btn-danger-my btn  btn-primary" type="button" onclick="dkinfoSaveOrUpdate();">保存</button>
				<button id="pkupdate" class="btn-danger-my btn  btn-primary" type="button" onclick="dkinfoSaveOrUpdate();">修改</button>
			</div>
		</div>
		<div class="business-manwife">列入呆账</div>
		<div style="padding: 15px">
			<table>
				<tr>
					<td><label><input type="checkbox" name="isBad" id="isBad" />列入呆账</label>&nbsp;</td>
					<td><input id="dateBad" type="text" placeholder="列入时间" class="smallicontm form-control" onclick="laydate()" />
					</li></td>
				</tr>
			</table>
		</div>
		<div class="business-manwife">代偿信息</div>
		<div class="business-padding" style="clear: none;"> 当前代偿总计:<input type="text" style="border: none;" readonly="readonly" id="currentTotal" />
			<div class="jqGrid_wrapper">
				<table id="table_list_10"></table>
				<div id="pager_list_10"></div>
			</div>
		</div>

		<div class="business-manwife">垫款收支记录</div>
		<div class="current-state-bno">
			<div class="submit-buttonleft">
				<button class="btn-danger-my btn  btn-success" type="button" onclick="dkszCreate();">新增</button>
			</div>
		</div>
		<div class="ibox-content" style="clear: none;">
			<div class="jqGrid_wrapper">
				<table id="table_list_4"></table>
				<div id="pager_list_4"></div>
			</div>
		</div>
		<div class="business-manwife">赔款信息</div>
		<div class="padding-nono">
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
				<tr>
					<td align="right"><label class="control-label np">赔款编号：</label>
					</td>
					<td><input class="form-control" type="text"
						id="numIndemnity" name="" /></td>

					<td align="right"><label class="control-label np">执行组别：</label>
					</td>
					<td><select class="select-control" required=""
						id="advanceExecutor" name=""></select></td>

					<td align="right"><label class="control-label np">赔款日期：</label>
					</td>
					<td><input class="smallicontm form-control"
						type="text" id="dateIndemnity" name=""
						onclick="laydate()" /></td>

				</tr>

				<tr>
					<td align="right"><label class="control-label np">赔款类别：</label>
					</td>
					<td><select class="select-control"
						id="pptypeIndemnity" name=""></select></td>

					<td align="right"><label class="control-label np">车辆拖回情况：</label>
					</td>
					<td><input class="form-control" type="text"
						id="infoTrailer" name="" /></td>

					<td align="right"><label class="control-label np">车辆拍卖情况：</label>
					</td>
					<td><input class="form-control" type="text"
						id="infoAuction" name="" /></td>

				</tr>
				<tr>
					<td align="right" valign="top"><label
						class="control-label np">赔款信息备注：</label></td>
					<td colspan="5"><textarea class="form-control"
							id="remarkIndemnity" name=""></textarea></td>
				</tr>
			</table>
		</div>
		<div class="business-manwife">赔款收支记录</div>
		<div class="current-state-bno">
			<div class="submit-buttonleft">
				<button class="btn-danger-my btn  btn-success"
					type="button" onclick="pkszCreate();">新增</button>
			</div>
		</div>
		<div class="ibox-content" style="clear: none;">
			<div class="jqGrid_wrapper">
				<table id="table_list_5"></table>
				<div id="pager_list_5"></div>
			</div>
		</div>
		<div class="business-manwife">追偿收支记录</div>
		<div class="current-state-bno">
			<div class="submit-buttonleft">
				<button class="btn-danger-my btn  btn-success"
					type="button" onclick="zcszCreate();">新增</button>
			</div>
		</div>
		<div class="ibox-content" style="clear: none;">
			<div class="jqGrid_wrapper">
				<table id="table_list_6"></table>
				<div id="pager_list_6"></div>
			</div>
		</div>
		
		<div class="business-manwife">备注信息</div>
		<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
			<tr>
				<td align="right" valign="top"><label class="control-label np">备注信息：</label></td>
				<td><textarea id="otherRemark" rows="3" cols="150" class="form-control"></textarea></td>
			</tr>
		</table>	
	</form>
	
	<%@include file="/jsp/comm_js_include.jsp"%>
	<script type="text/javascript">
	var winWidthdk = $("#table_list_4").parent('div.ibox-content').width();
	var winHeightdk = $(window).height() / 2.5;
	var getdkszData=function(){
	    var win = winWidth / 7 - 60;
 	    $.jgrid.defaults.styleUI = 'Bootstrap';
		$("#table_list_4").jqGrid({
			show:false,
			url:'${basePath}/DhAdvanceSublistController/list',
	       	datatype : "json",
	       	postData:{"busiId":$.getUrlData("busiId")},
		    colNames : ['id','凭证编号','交易日期','收/支', '金额','账户性质', '负责人','经办人', '记录时间', '备注'],
		    colModel : [ 
		    	 {name: 'replaceId',hidden:true},
	             {name: 'numVoucher',index: 'numVoucher',width: win,align: "center",sorttype: "float"},
	             {name: 'dateDeal',index: 'dateDeal',width: win,align: "center",sorttype: "float",formatter:function(a,b,c){
                   	 return formateStringDate(a);
                 }},
	             {name: 'fundDirection',index: 'fundDirection',width: win,align: "center",sorttype: "float",formatter:function(cellvalue, options, rowObject){
	            	 if(cellvalue == "01"){  
	                     return "收入";   
	                 }else{  
	                     return "支出";   
	                 }  
	             }},
	             {name: 'amount',index: 'amount',width: win,align: "center",sorttype: "float"},
	             {name: 'advanceAccountNatureDisplay',index: 'advanceAccountNature',width: win,align: "center",sorttype: "float"},
	             {name: 'operator',index: 'operator',width: win,align: "center",sorttype: "float"},
	             {name: 'created',index: 'created',width: win,align: "center",sorttype: "float",hidden:true},
	             {name: 'kdszDate',index: 'created',width: win,align: "center",sorttype: "float"},
	             {name: 'remarks',index: 'remarks',width: win,align: "center",sorttype: "float"}
	             ],
	           mtype : "post",
	           height: 200,
	           width:winWidthdk,  
	           autowidth: false,
	           shrinkToFit: false,
	           rowNum: 15,
	           rowList: [15, 30, 45],
	           viewrecords: true,
	           pager: "#pager_list_4",
	           hidegrid: false,
	           multiselect : false,		//实现单选    multiboxonly:true   beforeSelectRow: true,
	           multiboxonly:false,  
	           altRows:true,
	           altclass:'someClass',
	           beforeSelectRow: false,
	           jsonReader: {
	                root: "result.rows",
	                page: "result.page",
	                total: "result.total",
	                records: "result.records",
	                repeatitems: false,
	                id: "replaceId"
	            },
	            loadComplete:function(datas){
	          	  if (datas.flag == "100100") {
	                   // layer.msg("查询成功!", {icon: 6, time: 1000});
	                    return;
	                }
	          	  if(datas.flag == '100802') {
	  				  top.location.href = thisLoginUrl;
	  				  return;
	  			  }

	          	  layer.msg(datas.message, {icon: 2});
	            }
	      });
 	}
	
	var getpkszData=function(){
  	    var win = winWidth / 8 -50;
 	    $.jgrid.defaults.styleUI = 'Bootstrap';
		$("#table_list_5").jqGrid({
			show:false,
			url:'${basePath}/DhAdvanceIndemnityController/list',
	       	datatype : "json",
	       	postData:{"busiId":$.getUrlData("busiId")},
		    colNames : ['id','凭证编号','交易日期','收/支', '金额','项目名称', '负责人','经办人', '记录时间', '备注'],
		    colModel : [ 
		    	{name: 'replaceId',index: 'id',hidden:true},
	             {name: 'numVoucher',index: 'numVoucher',width: win,align: "center",sorttype: "float"},
	             {name: 'dateDeal',index: 'dateDeal',width: win,align: "center",sorttype: "float"},
	             {name: 'fundDirection',index: 'fundDirection',width: win,align: "center",sorttype: "float",formatter:function(cellvalue, options, rowObject){
	            	 if(cellvalue == "01"){  
	                     return "收入";   
	                 }else{  
	                     return "支出";   
	                 }  
	             }},
	             {name: 'amount',index: 'amount',width: win,align: "center",sorttype: "float"},
	             {name: 'typeIndemnityDisplay',index: 'typeIndemnity',width: win,align: "center",sorttype: "float"},
	             {name: 'operator',index: 'operator',width: win,align: "center",sorttype: "float"},
	             {name: 'created',index: 'created',width: win,align: "center",sorttype: "float"},
	             {name: 'kdszDate',index: 'created',width: win,align: "center",sorttype: "float"},
	             {name: 'remarks',index: 'remarks',width: win,align: "center",sorttype: "float"}
	             ],
	             mtype : "post",
	           height: 200,
	           width:winWidthdk,  
	           autowidth: false,
	           shrinkToFit: false,
	           rowNum: 15,
	           rowList: [15, 30, 45],
	           viewrecords: true,
	           pager: "#pager_list_5",
	           hidegrid: false,
	           multiselect : false,		//实现单选    multiboxonly:true   beforeSelectRow: true,
	           multiboxonly:false,
	           altRows:true,
	           altclass:'someClass',
	           beforeSelectRow: false,
	           jsonReader: {
	                root: "result.rows",
	                page: "result.page",
	                total: "result.total",
	                records: "result.records",
	                repeatitems: false,
	                id: "replaceId"
	            },
	            loadComplete:function(datas){
	          	  if (datas.flag == "100100") {
	                   // layer.msg("查询成功!", {icon: 6, time: 1000});
	                    return;
	                }
	          	  if(datas.flag == '100802') {
	  				  top.location.href = thisLoginUrl;
	  				  return;
	  			  }

	          	  layer.msg(datas.message, {icon: 2});
	            }
	      });
 	}
	
	var getzcszData=function(){
  	    var win = winWidth / 7 - 60;
 	    $.jgrid.defaults.styleUI = 'Bootstrap';
		$("#table_list_6").jqGrid({
			show:false,
			url:'${basePath}/DhAdvancePursuingController/list',
	       	datatype : "json",
	    	postData:{"busiId":$.getUrlData("busiId")},
		    colNames : ['id','凭证编号','交易日期','收/支', '金额','委外公司名', '负责人','经办人', '记录时间', '备注'],
		    colModel : [ 
		    	{name: 'replaceId',index: 'id',hidden:true},
	             {name: 'numVoucher',index: 'numVoucher',width: win,align: "center",sorttype: "float"},
	             {name: 'dateDeal',index: 'dateDeal',width: win,align: "center",sorttype: "float"},
	             {name: 'fundDirection',index: 'fundDirection',width: win,align: "center",sorttype: "float",formatter:function(cellvalue, options, rowObject){
	            	 if(cellvalue == "01"){  
	                     return "收入";   
	                 }else{  
	                     return "支出";   
	                 }  
	             }},
	             {name: 'amount',index: 'amount',width: win,align: "center",sorttype: "float"},
	             {name: 'companyEntrust',index: 'companyEntrust',width: win,align: "center",sorttype: "float"},
	             {name: 'operator',index: 'operator',width: win,align: "center",sorttype: "float"},
	             {name: 'created',hidden:true},
	             {name: 'kdszDate',index: 'created',width: win,align: "center",sorttype: "float"},
	             {name: 'remarks',index: 'remarks',width: win,align: "center",sorttype: "float"}
	             ],
	           mtype : "post",
	           height: 200,
	           width:winWidthdk,  
	           autowidth: false,
	           shrinkToFit: false,
	           rowNum: 15,
	           rowList: [15, 30, 45],
	           viewrecords: true,
	           pager: "#pager_list_6",
	           hidegrid: false,
	           multiselect : false,		//实现单选    multiboxonly:true   beforeSelectRow: true,
	           multiboxonly:false, 
	           altRows:true,
	           altclass:'someClass',
	           beforeSelectRow: false,
	           jsonReader: {
	                root: "result.rows",
	                page: "result.page",
	                total: "result.total",
	                records: "result.records",
	                repeatitems: false,
	                id: "replaceId"
	            },
	            loadComplete:function(datas){
	          	  if (datas.flag == "100100") {
	                   // layer.msg("查询成功!", {icon: 6, time: 1000});
	                    return;
	                }
	          	  if(datas.flag == '100802') {
	  				  top.location.href = thisLoginUrl;
	  				  return;
	  			  }

	          	  layer.msg(datas.message, {icon: 2});
	            }
	      });
 	}
	
	var getDcData=function(){
		var winWidth = $("#table_list_10").parent('div.ibox-content').width();
    	var winHeight = $(window).height() / 2.5;
     	var win = winWidth /5;
 	    $.jgrid.defaults.styleUI = 'Bootstrap';
 	    var data={};
 	    data.busiId=$.getUrlData("busiId");
 	    data.statusInstead=30;
		$("#table_list_10").jqGrid({
			show:false,
			url:'${basePath}/DhInsteadPaymentApplyController/listWithoutPage',
			postData:data,
	       	datatype : "json",
		    colNames : ['打款时间','代偿金额'],
		    colModel : [ 
	             {name: 'dateInstead',index: 'dateInstead',width: win,align: "center",sorttype: "float",formatter:function(a,b,c){
                   	 return formateStringDate(a);
                 }},
	             {name: 'amountInstead',index: 'amountInstead',width: win,align: "center",sorttype: "float"}
	             ],
	           mtype : "post",
	           height: 200,
	           width:winWidthdk,  
	           autowidth: false,
	           shrinkToFit: false,
	           rowNum: 15,
	            rowList: [15, 30, 45],
	           viewrecords: true,
	           hidegrid: false,
	           multiselect : false,		//实现单选    multiboxonly:true   beforeSelectRow: true,
	           multiboxonly:false,  
	           beforeSelectRow: false,
	           altRows:true,
	           altclass:'someClass',
	           loadComplete:function(datas){
	            	  if (datas.flag == "100100") {
	            		  var data=datas.result.rows;
	            		  var count=0;
	            		  for(var i=0;i<data.length;i++){
	            			  count +=data[i].amountInstead;
	            		  }
	                      $("#currentTotal").val(count);
	                      return;
	                  }
	            	  if (datas.flag == "100200") {
	                      $.fn.showDatas({"datas": datas});
	                      return;
	                  }
	                  layer.msg(datas.message, {icon: 2});
	              },
	           jsonReader: {
	                root: "result.rows",
	                page: "result.page",
	                total: "result.total",
	                records: "result.records",
	                repeatitems: false,
	                id: "replceId"
	            },
	            loadComplete:function(datas){
	          	  if (datas.flag == "100100") {
	                    //layer.msg("查询成功!", {icon: 6, time: 1000});
	                    return;
	                }
	          	  if(datas.flag == '100802') {
	  				  top.location.href = thisLoginUrl;
	  				  return;
	  			  }

	          	  layer.msg(datas.message, {icon: 2});
	            }
	      });
 	}
 	
	
	var dkinfoSaveOrUpdate = function(){
    	var data={};
    	var dkInfoId=$("#dkInfoId").val();
    	var url='${basePath}/DhAdvanceController/save';
    	if(dkInfoId!=null && dkInfoId!=""){
    		data.id=dkInfoId;
    		url='${basePath}/DhAdvanceController/modify';
    	}
    	document.getElementById("isBad").checked?data.isBad=1 : data.isBad=0
    	data.dateBad=$("#dateBad").val();
    	data.totalAmountMarginAdvance=$("#totalAmountMarginAdvance").val();
    	data.totalAmountMarginTakeback=$("#totalAmountMarginTakeback").val();
    	data.amountIndemnity=$("#amountIndemnity").val();
    	data.balanceMarginAdvance=$("#balanceMarginAdvance").val();
    	data.totalAmountAdvance=$("#totalAmountAdvance").val();
    	data.totalAmountTackback=$("#totalAmountTackback").val();
    	data.balanceAdvance=$("#balanceAdvance").val();
    	data.totalBalanceAdvance=$("#totalBalanceAdvance").val();
    	data.numIndemnity=$("#numIndemnity").val();
    	data.advanceExecutor=$('#advanceExecutor option:selected').val();
    	data.dateIndemnity=$("#dateIndemnity").val();
    	data.typeIndemnity=$('#pptypeIndemnity option:selected').val();
    	data.infoTrailer=$("#infoTrailer").val();
    	data.infoAuction=$("#infoAuction").val();
    	data.remarkIndemnity=$("#remarkIndemnity").val();
    	data.remark=$("#otherRemark").val();
    	data.busiId= $.getUrlData("busiId");
    	data.cusId= $.getUrlData("cusId");
    	var validstatus = $("#commentForma").valid();
    	if(!validstatus){
    		layer.msg('有验证未通过，请仔细检查!',{icon: 5});
    		return;
    	}
       	$.dpAjax({
       		show:false,
    		url:url,
    		data:data,
   			success: function(datas){
   				layer.msg('执行成功！', {icon: 6});
				return;
                }
    	});
    }
	
	var getDkDataById=function(){
		var data={};
		data.busiId=$.getUrlData("busiId");
		$.dpAjax({
			show:false,
    		url:'${basePath}/DhAdvanceController/list',
			data:data,
			success: function(datas){
				  var data=datas.result.rows;
				  if(data.length>0){
					  $("#dkInfoId").val(data[0].replaceId);
					  $("#dateBad").val(data[0].dateBad);
					  if(data[0].isBad==1){
						  $("#isBad").attr("checked", "checked"); 
					  }
					  $("#totalAmountMarginAdvance").val(data[0].totalAmountMarginAdvance);
					  $("#totalAmountMarginTakeback").val(data[0].totalAmountMarginTakeback);
					  $("#amountIndemnity").val(data[0].amountIndemnity);
					  $("#balanceMarginAdvance").val(data[0].balanceMarginAdvance);
					  $("#totalAmountAdvance").val(data[0].totalAmountAdvance);
					  $("#totalAmountTackback").val(data[0].totalAmountTackback);
					  $("#balanceAdvance").val(data[0].balanceAdvance);
					  $("#totalBalanceAdvance").val(data[0].totalBalanceAdvance);
					  
					  $("#numIndemnity").val(data[0].numIndemnity);
			          $("#advanceExecutor").val(data[0].advanceExecutor);
			          $("#dateIndemnity").val(data[0].dateIndemnity);
			          $("#pptypeIndemnity").val(data[0].typeIndemnity);
			          $("#infoTrailer").val(data[0].infoTrailer);
			          $("#infoAuction").val(data[0].infoAuction);
			          $("#remarkIndemnity").val(data[0].remarkIndemnity);
			          $("#otherRemark").val(data[0].remark);
					  $("#pksave").hide();
					  $("#pkupdate").show();
					  return;
            	}
			}
    	});
 	}
	
	</script>